﻿<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wpf="http://wpfcontrols.com/"
        xmlns:local="clr-namespace:WpfControls.Test"
        Title="Run"
        SizeToContent="WidthAndHeight"
        ResizeMode="NoResize"
        Padding="10">
    <Window.Resources>
        <local:FilesystemSuggestionProvider x:Key="fsp" />
        <DataTemplate x:Key="fsTemplate">
            <Border Padding="5">
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding Path=Name}"
                               FontWeight="Bold" />
                    <TextBlock Text="{Binding Path=LastWriteTime, StringFormat='Last Modified: {0}'}" />
                </StackPanel>
            </Border>
        </DataTemplate>
    </Window.Resources>
    <Grid Width="400"
          Margin="20"
          HorizontalAlignment="Center"
          VerticalAlignment="Center">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Label Content="_Open" />
        <wpf:AutoCompleteTextBox VerticalAlignment="Top"
                                 Height="25"
                                 Grid.Column="1"
                                 DisplayMember="FullName"
                                 ItemTemplate="{StaticResource ResourceKey=fsTemplate}"
                                 Watermark="Search here"
                                 IconPlacement="Left"
                                 IconVisibility="Visible"
                                 Provider="{StaticResource ResourceKey=fsp}">
            <wpf:AutoCompleteTextBox.SelectedItem>
                <Binding Path="SelectedPath" Mode="TwoWay">
                    <Binding.ValidationRules>
                        <local:RequiredValidationRule/>
                    </Binding.ValidationRules>
                </Binding>
            </wpf:AutoCompleteTextBox.SelectedItem>
            <wpf:AutoCompleteTextBox.LoadingContent>
                <TextBlock Text="Loading..."
                           Margin="5"
                           FontSize="14" />
            </wpf:AutoCompleteTextBox.LoadingContent>
            <wpf:AutoCompleteTextBox.Icon>
                <Border Width="20"
                        Height="20">
                    <Image Source="Resources/search_icon.png"
                           Height="16"
                           Width="16"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center" />
                </Border>
            </wpf:AutoCompleteTextBox.Icon>
        </wpf:AutoCompleteTextBox>
        <StackPanel Grid.Column="1"
                    Grid.Row="1"
                    Margin="0,10"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
            <Button Content="Open"
                    Command="{Binding Path=OpenCommand}"
                    Padding="20,3" />
            <Button Content="Cancel"
                    Margin="5,0"
                    Command="{Binding Path=CancelCommand}"
                    Padding="20,3" />
        </StackPanel>
    </Grid>
</Window>
